const arr = [
  { 'a': {a:1} },
  { 'a|b|c|d': {d:4} },
  { 'a|b|c': {c:3}},

  { ab: {b:2} },
  // { '选项一｜选项二': '1111111'}
]

arr.sort((a,b) => a-b)
console.log(arr)


let newArr = [];
let letterARR = ['A', 'B', 'C', 'D']
let letter = []
let map = new Map()
let tem = 1, maxKey = ''
arr.forEach((item, index) => {
  let newObj = {};
  for (const key in item) {
    if(key.length > tem) {
      tem = key.length
      console.log(key)
      maxKey = key
      // 
      letter = letterARR(0,maxKey)
      // maxKey.split('')
      // const keyArr = maxKey.split('|')
      console.log(keyArr)

    }
    const l = letter.shift()
    newObj[l] = item[key]
  }
  //   newObj[key[i]] = item[Object.keys(item)[i]]
  // }
  newArr.push(newObj);
})

console.log(newArr);
console.log(tem)
